﻿var d = new Date();

var accessCount = 0;

var time = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
$("#endTime").val(time)
$("#beginTime").val("2021-02-25 00:00:00")
if (getUrlParam("isflag") == 230) {
  $("#beginTime").val(new Date(new Date().setDate((new Date().getDate() - 7))).Format("yyyy-MM-dd 00:00:00"));
}
var clickCarCount = 0;
var page = 1;
//获取父页面传来的id
//工程idGCMC
var devid = getUrlParam("devid")
//地图经纬度
var JWD = '';
var JWDNumArr = "";
var streetname = "";
var projectAddress = "";
var umgLon = '';
var umgLat = '';
//出入口集合
var GCMC = "";
var crkArray = [];
var carColor
var map;
var SHAPE = "";
var type = 1;
var crkFlag = '';
var url = "/VIAS/web/ztc/ztcjgFindByMuckTruck"
//卡口列表
var deviceIds = ''
//页数
var totalPages
var deviceBase = '';
var BXKK = `
11010812001320012202
    11010830001320030001,
    11010830001220532691,
    11010830001320030002,
    11010830001320030003,
    11010830001320030004,
    11010830001320030005,
    11010830001320030006,
    11010830001320030007,
    11010830001320030008,
    11010830001320030009,
    11010830001320030010,
    11010830001320030011,
    11010830001320030012,
    11010830001320030013,
    11010830001320030014,
    11010830001320030015,
    11010830001320030016,
    11010830001320030017,
    11010830001320030018,
    11010830001320030019,
    11010830001320030020,
    11010830001320030021,
    11010830001320030022,
    11010830001320030023,
    11010830001320030024,
    11010830001320030025,
    11010830001320030026,
    11010830001320030027,
    11010830001320030028,
    11010830001320030029,
    11010830001320030030,
    11010830001320030031,
    11010830001320030032,
    11010830001320030033,
    11010830001320030034,
    11010830001320030035,
    11010830001320030036,
    11010830001320030037,
    11010830001320030038,
    11010830001320030039,
    11010830001320030040,
    11010830001320030041,
    11010830001320030042,
    11010830001320030043,
    11010830001320030044,
    11010830001320030045,
    11010830001320030046,
    11010830001320030047,
    11010830001320030048,
    11010830001320030049,
    11010830001320030050,
    11010830001320030051,
    11010830001320030052,
    11010830001320030053,
    11010830001320030054,
    11010830001320030055,
    11010830001320030056,
    11010830001320030057,
    11010830001320030058,
    11010830001320030059,
    11010830001320030060,
    11010830001320030061,
    11010830001320030062,
    11010830001320030063,
    11010830001320030064,
    11010830001320030065,
    11010830001320030066,
    11010830001320030067,
    11010830001320030068,
    11010830001320030069,
    11010830001320030070,
    11010830001320030071,
    11010830001320030072,
    11010830001320030073,
    11010830001320030074,
    11010830001320030075,
    11010830001320030076,
    11010830001320030077,
    11010830001320030078,
    11010830001320030079,
    11010830001320030080,
    11010830001320030081,
    11010830001320030082,
    11010830001320030083,
    11010830001320030084,
    11010830001320030085,
    11010830001320030086,
    11010830001320030087,
    11010830001320030088,
    11010830001320030089,
    11010830001320030090,
    11010830001320030091,
    11010830001320030092,
    11010830001320030093,
    11010830001320030094,
    11010830001320030095,
    11010830001320030096,
    11010830001320030097,
    11010830001320030098,
    11010830001320030099,
    11010830001320030100,
    11010830001320030101,
    11010830001320030102,
    11010830001320030103,
    11010830001320030104,
    11010830001320030105,
    11010830001320030106,
    11010830001320030107,
    11010830001320030108,
    11010830001320030109,
    11010830001320030110,
    11010830001320030111,
    11010830001320030112,
    11010830001320030113,
    11010830001320030114,
    11010830001320030115,
    11010830001320030116,
    11010830001320030117,
    11010830001320030118,
    11010830001320030119,
    11010830001320030120,
    11010830001320030121,
    11010830001320030122,
    11010830001320030123,
    11010830001320030124,
    11010830001320030125,
    11010830001320030126,
    11010830001320030127,
    11010830001320030128,
    11010830001320030129,
    11010830001320030130,
    11010830001320030131,
    11010830001320030133,
    11010830001320030134,
    11010830001320030135,
    11010830001320030136,
    11010830001320030137,
    11010830001320030138,
    11010830001320030139,
    11010830001320030140,
    11010830001320030141,
    11010830001320030142,
    11010830001320030143,
    11010830001320030144,
    11010830001320030145,
    11010830001320030146,
    11010830001320030147,
    11010830001320030148,
    11010830001220294347,
    11010819001320019568,
    11010815001320015740,
    11010815001320015778,
    11010818001310018044,
    11010099001310049306,
    11010819001320019564,
    11010808001320008539,
    11010808001320008551,
    11010808001320008079,
    11010808001320008075,
    11010808001320008071,
    11010808001320008075,
    11010828001320028185,
    11010818001310018013,
    11010815001320015765,
    11010825001320025158,
    11010899001310018348,
    11010815001320015794,
    11010818001310018025,
    11010823001320023614,
    11010807001320007210,
    11010830001220343113`;
BXKK = BXKK.split(",")

//判断是否等于113卡口
function IsBXKK (devid) {
  var num = 0;
  $.each(BXKK, function (i, row) {
    if (row.indexOf(devid) >= 0) {
      num += 1;
    }
  })
  return num;
}

// 获取车身颜色
function choseColor (vehicleColor) {
  var result = "未知";
  if (vehicleColor == '1') {
    result = '黑';
  }
  if (vehicleColor == '9') {
    result = '绿';
  }
  if (vehicleColor == '0') {
    result = '未知';
  }
  if (vehicleColor == '18') {
    result = '深灰';
  }
  if (vehicleColor == '99') {
    result = '其他';
  }
  if (vehicleColor == '4') {
    result = '红';
  }
  if (vehicleColor == '6') {
    result = '黄';
  }
  if (vehicleColor == '11') {
    result = '青';
  }
  if (vehicleColor == '5') {
    result = '蓝';
  }
  if (vehicleColor == '10') {
    result = '紫';
  }
  if (vehicleColor == '12') {
    result = '粉';
  }
  if (vehicleColor == '8') {
    result = '棕';
  }
  if (vehicleColor == '2') {
    result = '白';
  }
  if (vehicleColor == '3') {
    result = '灰';
  }
  if (vehicleColor == '7') {
    result = '橙';
  }
  if (vehicleColor == '14') {
    result = '银';
  }
  if (vehicleColor == '15') {
    result = '褐';
  }
  if (vehicleColor == '16') {
    result = '银白';
  }
  if (vehicleColor == '17') {
    result = '深蓝';
  }
  if (vehicleColor == '13') {
    result = '金色';
  }
  carColor = result;
  return carColor;
}

var detailObj = {
  devid: [],
  index: 0,
  dataArr: [],
  plateColor: "",
  bool: 0,
  bool2: 0,
  bool3: 0,
  ztcdevid: '',
  deviceIds: [],
  page: 1,
  dwData1: []
}
//查询点击事件
$("#searchBtn").click(function () {
  get_checkbox_val();
  // searchGCGK();
  searchInfo(1, type);
});
// 向上翻页
$("#pagePlus").click(function () {
  if (page > 1) {
    page = page - 1;
    searchInfo(page - 1, type);
  } else {
    searchInfo(1, type);
  }
});
// 向下翻页
$("#pageMinus").click(function () {
  //var carColor = choseColor(page)
  if (page < total) {
    page = page + 1;
  } else {
    page = total
  }
  searchInfo(page, type);
});

$('#resetSearch').click(function () {
  // $('input[type=checkbox]').attr('checked', false);
  $('input[type=checkbox]').prop('checked', false);
  $("#plateNo").val("");
})

function getzyzAction () {
  var obj = document.getElementsByName("hege");
  var check_val = [];
  for (k in obj) {
    if (obj[k].checked)
      check_val.push(Number(k) - 1);
  }
  return check_val.join(',');
}

//获取查询条件 全 部  合规车辆 违规车辆（  未备案  未苫盖  未清洗  有遮挡 )
var ids = '';
var JXX = 'false';
var YCHP = 'false';
var isWSG = 'false';
var labelType = '';
var caseFlag = '';
var showNoPlate_flag = false;

$("#wzyz").change(function () {
  if (!$("#wzyz")[0].checked) {
    labelType = '';
  }
})

$("#isWSG").change(function () {
  if (!$("#isWSG")[0].checked) {
    labelType = '';
  }
})

$("#YCHP").change(function () {
  if (!$("#YCHP")[0].checked) {
    labelType = '';
  }
})

$("#JXX").change(function () {
  if (!$("#JXX")[0].checked) {
    labelType = '';
  }
})

function get_checkbox_val () {

  ids = getzyzAction();
  if ($("#JXX")[0].checked) {
    JXX = 'true';
    caseFlag = '5';
  } else {
    JXX = 'false';
  }
  if ($("#showNoPlate")[0].checked) {
    showNoPlate_flag = true;
    caseFlag = '3';
  } else {
    showNoPlate_flag = false;
  }

  if ($("#YCHP")[0].checked) {
    YCHP = 'true';
    labelType = '3'
    caseFlag = '1';
  } else {
    YCHP = 'false';
  }

  if ($("#wzyz")[0].checked) {
    caseFlag = '2';
  }

  if ($("#isWSG")[0].checked) {
    isWSG = 'true';
    caseFlag = '4';
    labelType = '1'
  } else {
    isWSG = 'false';
  }
  if (JXX || YCHP || isWSG && ids == '') {

  }
}

function unFind (data) {
  if (data === null || data === undefined || data === 'NaN-aN-aN') {
    return "暂无信息"
  }
  return data
}

//日期格式化
Date.prototype.format = function (fmt) {
  var o = {
    "M+": this.getMonth() + 1, //月份
    "d+": this.getDate(), //日
    "h+": this.getHours(), //小时
    "m+": this.getMinutes(), //分
    "s+": this.getSeconds(), //秒
    "q+": Math.floor((this.getMonth() + 3) / 3), //季度
    "S": this.getMilliseconds() //毫秒
  };
  if (/(y+)/.test(fmt)) {
    fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  }
  for (var k in o) {
    if (new RegExp("(" + k + ")").test(fmt)) {
      fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    }
  }
  return fmt;
}


//获取工程概况
function searchGCGK () {
  accessCount = accessCount + 1;
  var data;
  if (accessCount == 1) {
    data = {
      page: 1,
      pageCount: 10,
      buildingSiteNum: getUrlParam("devid")
    }
  } else {
    data = {
      page: 1,
      pageCount: 10,
      projectId: getUrlParam("devid")
    }
  }


  var json = JSON.stringify(data);
  $.ajax({
    type: 'get',
    contentType: "application/json;charset=UTF-8",
    data: {
      json: json.replace(/[\r\n]/g, "")
    },
    // url: siteUrl_port + "/VIAS/web/site/findSite",
    // url: "http://11.16.125.16:5220/vias/web/zfld/zdqy/siteZHQuery",
    url: siteUrl_port + "/vias/web/zfld/zdqy/siteZHQuery",
    async: false,
    success: function (data) {
      console.log()
      data = JSON.parse(data.replace(/[\r\n]/g, ""))
      var point = getUrlParam("point");
      JWDNumArr = point.split(",")
      data = data.data.list[0]
      initDeviceId();
      $("#GCGK").empty();
      $("#GD_total").empty();
      if (data == undefined) {
        searchGCGK();
      } else {

        if (data.centralLat != null) {
          umgLat = data.centralLat
        }

        if (data.centralLon != null) {
          umgLon = data.centralLon
        }


        if (data.projectAddress != null) {
          projectAddress = data.projectAddress
        }
        if (data.street != null) {
          streetname = data.street
        }
        if (data.projectName !== null) {
          $("#GD_total").append("" +
            data.projectName);
          GCMC = data.projectName;
        } else if (data.projectAddress != null) {
          $("#GD_total").append("" +
            data.projectAddress);
          $("#ztcjgBTN").hide();
        } else {
          $("#GD_total").append("" +
            "暂无信息");
          $("#ztcjgBTN").hide();
        }
        if (data.coordinates !== null) {
          SHAPE = data.coordinates;
        }
        var peroson = ' ';
        if (data.constructionUnitManager !== null) {
          peroson = "" +
            "<img src='/ditu/images/ztcjg_icon1.png'>" +
            "<div><span><p>负责人:</p>" +
            "<p><span>" + data.constructionUnitManager + "</span></p></div></div>"
        } else {
          peroson = "<img src='/ditu/images/ztcjg_icon1.png'>" +
            "<div><span><p>负责人:</p>" +
            "<p><span>暂无</p></div></div>"
        }
        $("#GCGK").append(" " +
          "<div class='ztcjg_left_img'>"
          //+"<img src=''></div>"
          +
          "<div class='ztcjg_left_tit'><h3>工程概况</h3></div><div class='ztcjg_left_user'>"
          // + "<img src='/ditu/images/ztcjg_icon1.png'>"
          //+ "<div><p>负责人</p>"
          // + "<p><span>罗洋 13532163274</span></p>"
          // + "<p><span>罗洋 13532163274</span></p></div></div>"
          +
          peroson +
          "<div><p></p>" +
          "<p><span></span></p>" +
          "<p><span></span></p></div></div>"
          //+ "<p><span>工程名称：</span>" + data.GCMC + "</p>"
          +
          "<div class='gdxx_right_item'><label>施工许可证：</label><span>" + unFind(data.constructionPermitNum) + "</span></div>" +
          "<div class='gdxx_right_item'><label>工程性质：</label><span>" + unFind(data.projectProperties) + "</span></div>" +
          "<div class='gdxx_right_item'><label>建设地点：</label><span>" + unFind(data.projectAddress) + "</span></div>" +
          "<div class='gdxx_right_item'><label>建设单位：</label><span>" + unFind(data.buildUnitName) + "</span></div>" +
          "<div class='gdxx_right_item'><label>施工单位：</label><span>" + unFind(data.constructionUnitName) + "</span></div>" +
          "<div class='gdxx_right_item'><label>监理单位：</label><span>" + unFind(data.supervisionUnitName) + "</span></div>" +
          "<div class='gdxx_right_item'><label>形象进度：</label><span>" + unFind(data.projectImageProgress) + "</span></div>" +
          "<div class='gdxx_right_item'><label>管辖科室：</label><span>" + unFind(data.administrativeDepartment) + "</span></div>" +
          "<div class='gdxx_right_item'><label>所属街道：</label><span>" + unFind(data.street) + "</span></div>" +
          "<div class='gdxx_right_item'><label>建筑面积(平方米/延米)：</label><span>" + unFind(data.floorage) + "</span></div>" +
          "<div class='gdxx_right_item'><label>工程性质：</label><span>" + unFind(data.projectStatus) + "</span></div>" +
          "<div class='gdxx_right_item'><label>工程目前状态：</label><span>" + unFind(data.projectStatus) + "</span></div>" +
          "<div class='gdxx_right_item'><label>创建时间：</label><span>" + unFind(new Date(data.createTime).format("yyyy-MM-dd")) + "</span></div>" +
          "<div class='gdxx_right_item'><label>修改时间：</label><span>" + unFind(new Date(data.updateTime).format("yyyy-MM-dd")) + "</span></div>"
        )
      }
    }
  })
}

//查询工地源头详情周边疑似工地
var baiduMarker = [];
var ysgdCount = 0;

function queryZBYSGD () {
  var points = getUrlParam("point")
  var pointss = points.split(",");
  var circle = new BMap.Circle(new BMap.Point(pointss[1], pointss[0]), 500, {
    strokeColor: "blue",
    strokeWeight: 2,
    strokeOpacity: 0.5
  });
  var html_ = ``;
  var html2_ = ``;
  $.ajax({
    type: 'GET',
    dataType: "json",
    // url: ZTCUrl + "/VIAS/web/ztc/warningGZCar",
    url: gdUrl_port + "/vias/web/baidu/queryYPSite",
    // url: "http://127.0.0.1:8014/vias/web/baidu/queryYPSite",
    success: function (data) {
      $.each(data, function (i, row) {
        var point = row.point.split(",");
        if (BMapLib.GeoUtils.isPointInCircle(new BMap.Point(point[1], point[0]), circle)) {
          ysgdCount += 1;
          var myIcon = null;
          // 创建信息窗口对象
          if (row.count == "") {
            myIcon = new BMap.Icon("/ditu/images/orange20x20.gif", new BMap.Size(20, 20));
            myIcon.setImageSize(new BMap.Size(20, 20))
          } else if (row.count <= 5) {
            myIcon = new BMap.Icon("/ditu/images/orange20x20.gif", new BMap.Size(25, 25));
            myIcon.setImageSize(new BMap.Size(25, 25))
          } else if (row.count > 5 && row.count <= 10) {
            myIcon = new BMap.Icon("/ditu/images/orange20x20.gif", new BMap.Size(32, 32));
            myIcon.setImageSize(new BMap.Size(32, 32))
          } else if (row.count > 10) {
            myIcon = new BMap.Icon("/ditu/images/orange20x20.gif", new BMap.Size(38, 38));
            myIcon.setImageSize(new BMap.Size(38, 38))
          }
          var marker = new BMap.Marker(new BMap.Point(point[1], point[0]), {
            offset: new BMap.Size(0, 3),
            icon: myIcon
          });
          map.addOverlay(marker)
          marker.addEventListener("click", function (event) {
            var display = $(".sp_right1").css("display");
            if (event.clientY > 300) {
              event.clientY = 300;
            }
            if (event.clientX > 1450) {
              event.clientX -= 350;
            };
            var address = distanceAddress(point[1].substring(0, point[1].length - 1), point[0]);
            $(".sp_right1").css("display", "block");
            $(".sp_right1").css("left", event.clientX + 20);
            $(".sp_right1").css("top", event.clientY);
            $(".project_name1").html("<label>类型：</label>疑似工地");
            $(".building_address1").html("<label>地址：</label>" + address);
            $(".licence1").html("<label>经过车辆次数：</label>" + row.gps_count);
            var plateNo = row.plateno.split(",");
            var html_ = `<tr>
                        <td>序号</td>
                        <td>车牌号</td>
                        <td>经过次数</td>
                    </tr>`;
            if (plateNo.length > 0) {
              $.each(plateNo, function (i, row) {

                html_ += `<tr onclick="showmotor2('${row.split(":")[0]}','${point[1]}','${point[0]}')">
                        <td>${i + 1}</td>
                        <td>${row.split(":")[0]}</td>
                        <td>${row.split(":")[1]}</td>
                    </tr>`
              })

            }
            $("#gcgjlist1").html(html_);
          });

          var address = distanceAddress(point[1].substring(0, point[1].length - 1), point[0]);
          $(".sp_right").css("display", "block");
          $(".sp_right").css("left", event.clientX + 20);
          $(".sp_right").css("top", event.clientY);
          $(".project_name").html("<label>类型：</label>疑似工地");
          html_ += `<p><label>地址：</label>${address == "" ? "暂无" : address}</p>
                    <br> <p><label>GPS研判渣土车</label></p><br>
                    <p><label>进出频次：</label>${row.gps_count == "" ? 0 : row.gps_count}</p>
                    <p><label>研判时间：</label>${row.REQUEST_ID}</p>`;
          // marker.hide();
          baiduMarker.push(marker);

        }
      })
      if (ysgdCount == 0) {
        $(".sp_right").css("display", "none");
      } else {
        $(".sp_right").css("display", "block");
      }
      $(".building_address").html(html_);
    }
  })

  // $(".licence").html(html2_);
}

$("#closecar").click(function () {
  $(".sp_right1").css("display", "none");
})
//跳转轨迹
showmotor2 = function (plateNo, lng, lat) {
  var parma = '?plateNo=' + encodeURIComponent(plateNo) +
    '&lng=' + lng + '&lat=' + lat +
    '&parentObj=vehicleTrajectoryObj';
  layui.use('layer', function () {
    var layer = layui.layer;
    layer.open({
      type: 2,
      fixed: true,
      title: ['车辆实时轨迹分析', 'font-size: 22px;color: rgb(49, 70, 89);'],
      closeBtn: 1,
      scrollbar: false,
      maxmin: false,
      content: '/vias_app/views/vias/Map/VehicleGroundAssociationCS.html' + parma,
      area: ['100%', '100%'],
      end: function () {
        // 暂时不用
      }
    });
  });
}

//周边卡口乱码时使用
// function spkinof() {
//     var img = new Image();
//     img.src = '/vias_app/static/vias/images/wkkNew.png';
//     var img1 = new Image();
//     img1.src = '/vias_app/static/vias/images/spkNew.png';
//     var img2 = new Image();
//     img2.src = '/vias_app/static/vias/images/crk1.png';
//     var coordinatesDataImg = [];
//     var coordinatesData = [];
//
//     var dwData = JSON.parse(localStorage.getItem("dwData"))
//     var circle = new BMap.Circle(new BMap.Point(JWDNumArr[1], JWDNumArr[0]), 1500, {
//         strokeColor: "blue",
//         strokeWeight: 2,
//         strokeOpacity: 0.5
//     });
//     $.each(dwData, function (i, row) {
//         if (BMapLib.GeoUtils.isPointInCircle(new BMap.Point(row.coordinates[0], row.coordinates[1]), circle)) {
//             if (row.bayonet == "0" || row.bayonet == 0) {
//                 coordinatesDataImg.push({
//                     geometry: {
//                         type: 'Point',
//                         coordinates: row.coordinates,
//                         devname: row.devName,
//                         devid: row.devId,
//                         bayonet: row.bayonet,
//                         streetname: row.streetname
//                     },
//                     icon: img1
//                 })
//             } else {
//                 coordinatesData.push({
//                     geometry: {
//                         type: 'Point',
//                         coordinates: row.coordinates,
//                         devname: row.devName,
//                         devid: row.devId,
//                         bayonet: row.bayonet,
//                         streetname: row.streetname
//                     },
//                     icon: img
//                 })
//             }
//         }
//     })
//     var mousemoveItem1 = null;
//     var dataSet1 = new mapv.DataSet(coordinatesData);
//     var options = {
//         draw: 'icon',
//         methods: {
//             click: function (item, event) { // 鼠标移动事件，对应鼠标经过的元素对象值
//                 if (map.getZoom() >= 15 && item) {
//                     // console.log(item)
//                     // console.log(event);
//                     bayonetwkk(item);
//                 }
//             },
//             mousemove: function (item) {
//                 mousemoveItem1 = item;
//             }
//         },
//         width: 20, // 规定图像的宽度
//         height: 20,
//         size: 20, // 规定图像的高度
//     }
//     var dataSet = new mapv.DataSet(coordinatesDataImg);
//     var optionsImg = {
//         draw: 'icon',
//         methods: {
//             click: function (item, event) { // 鼠标移动事件，对应鼠标经过的元素对象值
//                 if (map.getZoom() >= 15 && item) {
//                     // console.log(item)
//                     // console.log(event);
//                     bayonet(item);
//                 }
//             },
//             mousemove: function (item) {
//                 if (item || mousemoveItem1) {
//                     map.setDefaultCursor('pointer');
//                 } else {
//                     map.setDefaultCursor('default');
//                 }
//             }
//         },
//         width: 20, // 规定图像的宽度
//         height: 20,
//         size: 20, // 规定图像的高度
//     }
//
//     var sxtvLayer1 = new mapv.baiduMapLayer(map, dataSet, optionsImg);
//     var sxtvLayer2 = new mapv.baiduMapLayer(map, dataSet1, options);
//     setTimeout(function () {
//         sxtvLayer1.show();
//         sxtvLayer2.show();
//     }, 1000)
// }
//周边卡口不乱码时使用

function spkinof () {
  $.ajax({
    type: "get",
    dataType: "json",
    data: {
      httpurl: "roadseg?index=dugis_ut_awkk&type=default&location=" + JWDNumArr[0] + "," + JWDNumArr[1] + "&radius=" + 1000 + "&output=json&page_size=10000"
    },
    // url: siteUrl_ports + "/VIAS/web/snapshot/baidu/CircularSearch",
    url: 'http://11.16.127.79:5013/VIAS/web/snapshot/baidu/CircularSearch',
    success: function (data) {
      if (data.status == 0) {
        var img = new Image();
        img.src = '/vias_app/static/vias/images/wkkNew.png';
        var img1 = new Image();
        img1.src = '/vias_app/static/vias/images/spkNew.png';
        var img2 = new Image();
        img2.src = '/vias_app/static/vias/images/crk1.png';
        var coordinatesDataImg = [];
        var coordinatesData = [];
        $.each(data.results, function (i, row) {
          if (IsBXKK(row.devId) == 0) {
            if (row.devName.indexOf("JK") < 0 && row.devName.indexOf("IPC") < 0) {
              if (crkArray.length > 0) {
                var bool = 0;
                $.each(crkArray, function (i, row1) {
                  if (row.devId == row1.DEVICE_ID) {
                    bool = 1;
                    if (row.bayonet == "0" || row.bayonet == 0) {
                      coordinatesDataImg.push({
                        geometry: {
                          type: 'Point',
                          coordinates: row.location.coordinates,
                          devname: row.devName,
                          devid: row.devId,
                          bayonet: row.bayonet,
                          streetname: row.streetname
                        },
                        icon: img2
                      })
                    } else {
                      coordinatesData.push({
                        geometry: {
                          type: 'Point',
                          coordinates: row.location.coordinates,
                          devname: row.devName,
                          devid: row.devId,
                          bayonet: row.bayonet,
                          streetname: row.streetname
                        },
                        icon: img2
                      })
                    }

                  }
                })
                if (bool == 0) {
                  if (row.bayonet == "0" || row.bayonet == 0) {
                    coordinatesDataImg.push({
                      geometry: {
                        type: 'Point',
                        coordinates: row.location.coordinates,
                        devname: row.devName,
                        devid: row.devId,
                        bayonet: row.bayonet,
                        streetname: row.streetname
                      },
                      icon: img1
                    })
                  } else {
                    coordinatesData.push({
                      geometry: {
                        type: 'Point',
                        coordinates: row.location.coordinates,
                        devname: row.devName,
                        devid: row.devId,
                        bayonet: row.bayonet,
                        streetname: row.streetname
                      },
                      icon: img
                    })
                  }
                }

              } else {
                if (row.bayonet == "0" || row.bayonet == 0) {
                  coordinatesDataImg.push({
                    geometry: {
                      type: 'Point',
                      coordinates: row.location.coordinates,
                      devname: row.devName,
                      devid: row.devId,
                      bayonet: row.bayonet,
                      streetname: row.streetname
                    },
                    icon: img1
                  })
                } else {
                  coordinatesData.push({
                    geometry: {
                      type: 'Point',
                      coordinates: row.location.coordinates,
                      devname: row.devName,
                      devid: row.devId,
                      bayonet: row.bayonet,
                      streetname: row.streetname
                    },
                    icon: img
                  })
                }
              }
            }
          }
        })
        var mousemoveItem1 = null;
        var dataSet1 = new mapv.DataSet(coordinatesData);
        var options = {
          draw: 'icon',
          methods: {
            click: function (item, event) { // 鼠标移动事件，对应鼠标经过的元素对象值
              if (map.getZoom() >= 15 && item) {
                // console.log(item)
                // console.log(event);
                bayonetwkk(item);
              }
            },
            mousemove: function (item) {
              mousemoveItem1 = item;
            }
          },
          width: 20, // 规定图像的宽度
          height: 20,
          size: 20, // 规定图像的高度
        }
        var dataSet = new mapv.DataSet(coordinatesDataImg);
        var optionsImg = {
          draw: 'icon',
          methods: {
            click: function (item, event) { // 鼠标移动事件，对应鼠标经过的元素对象值
              if (map.getZoom() >= 15 && item) {
                // console.log(item)
                // console.log(event);
                bayonet(item);
              }
            },
            mousemove: function (item) {
              if (item || mousemoveItem1) {
                map.setDefaultCursor('pointer');
              } else {
                map.setDefaultCursor('default');
              }
            }
          },
          width: 20, // 规定图像的宽度
          height: 20,
          size: 20, // 规定图像的高度
        }

        var sxtvLayer1 = new mapv.baiduMapLayer(map, dataSet, optionsImg);
        var sxtvLayer2 = new mapv.baiduMapLayer(map, dataSet1, options);
        setTimeout(function () {
          sxtvLayer1.show();
          sxtvLayer2.show();
          // sxtvLayer1.hide();
          // sxtvLayer2.hide();
        }, 500)

      }

    }
  })
}

function unique (arr1) {
  const res = new Map();
  return arr1.filter((a) => !res.has(a.devId) && res.set(a.devId, 3))
}

function getCurrentDay (n) {
  var today = new Date(),
    date;
  return n ? (new Date(today.getTime() + n * 1000 * 60 * 60 * 24)).pattern("yyyy-MM-dd HH:mm:ss") : new Date().pattern("yyyy-MM-dd HH:mm:ss")
}


function bayonet (event) {
  var parma = "";
  if (event.geometry != null) {
    parma = '?deviceId=' + event.geometry.devid;
  } else {
    parma = '?deviceId=' + event.getAttribute("devid");
  }

  layui.use('layer', function () {
    var layer = layui.layer;
    layer.open({
      type: 2,
      fixed: true,
      title: ['卡口详情：<span style="font-size:15px">' + event.geometry.devname + '</span>', 'font-size: 22px;color: rgb(49, 70, 89);'],
      closeBtn: 1,
      scrollbar: false,
      maxmin: false,
      content: '/ditu/jiaotong/shishiSP1.html' + parma,
      area: ['50%', '75%'],
      cancel: function (index, layero) {
        stopflv();
      }
    });
  });
}

function bayonet (event) {
  var parma = "";
  var videoid = "";
  var devname = ""
  if (event.geometry != null) {
    parma = '?deviceId=' + event.geometry.devid;
    videoid = event.geometry.devid;
    devname = event.geometry.devname
  } else {
    parma = '?deviceId=' + event.getAttribute("devid");
    videoid = event.getAttribute("devid")
    devname = event.getAttribute("devname")
  }
  layui.use('layer', function () {
    var layer = layui.layer;
    layer.open({
      type: 2,
      fixed: true,
      title: ['卡口详情：<span style="font-size:15px">' + devname + '</span>', 'font-size: 22px;color: rgb(49, 70, 89);'],
      closeBtn: 1,
      scrollbar: false,
      maxmin: false,
      content: '/ditu/jiaotong/shishiSP1.html' + parma,
      area: ['50%', '75%'],
      cancel: function (index, layero) {
        videoDisplayFucStop(videoid);
      }
    });
  });
}

function bayonet1 (event) {


  var parma = "";
  var videoid = "";
  var devname = ""
  if (event.geometry != null) {
    parma = '?deviceId=' + event.geometry.devid;
    videoid = event.geometry.devid;
    devname = event.geometry.devname
  } else {
    parma = '?deviceId=' + event.getAttribute("devid");
    videoid = event.getAttribute("devid")
    devname = event.getAttribute("devname")
  }
  layui.use('layer', function () {
    var layer = layui.layer;
    layer.open({
      type: 2,
      fixed: true,
      title: ['卡口详情：<span style="font-size:15px">' + devname + '</span>', 'font-size: 22px;color: rgb(49, 70, 89);'],
      closeBtn: 1,
      scrollbar: false,
      maxmin: false,
      content: '/ditu/jiaotong/shishiSP2.html' + parma,
      area: ['50%', '75%'],
      cancel: function (index, layero) {
        nbkkListvideoDisplayFucStop179(videoid);
        // videoDisplayFucStop(videoid);
      }
    });
  });
}

function bayonetwkk (event) {
  var parma = "";
  var videoid = "";
  var devname = ""
  if (event.geometry != null) {
    parma = '?deviceId=' + event.geometry.devid;
    videoid = event.geometry.devid;
    devname = event.geometry.devname
  } else {
    parma = '?deviceId=' + event.getAttribute("devid");
    videoid = event.getAttribute("devid")
    devname = event.getAttribute("devname")
  }
  layui.use('layer', function () {
    var layer = layui.layer;
    layer.open({
      type: 2,
      fixed: true,
      title: ['卡口详情 <span style="font-size:15px">' + devname + '</span>', 'font-size: 22px;color: rgb(49, 70, 89);'],
      closeBtn: 1,
      scrollbar: false,
      maxmin: false,
      content: '/ditu/jiaotong/shishiSP.html' + parma,
      area: ['100%', '100%'],
      cancel: function (index, layero) {
        videoDisplayFucStop(videoid);
      }
    });
  });
}

function spkinof2 () {
  $.ajax({
    type: 'get',
    dataType: "JSON",
    contentType: "application/json",
    data: {
      id: devid
    },
    url: GDUrl + "/VIAS/web/snapshot/WorkSite/queryInfoById",
    success: function (data) {
      if (data.length > 0) {
        crkArray = data;
      }
      spkinof();
      $.each(data, function (i, row) {
        detailObj.dwData1.push(row);
        if (i == data.length - 1) {
          detailObj.ztcdevid += row.DEVICE_ID;
        } else {
          detailObj.ztcdevid += row.DEVICE_ID + ",";
        }
      })
      spkinof3();
    }
  });
}

//初始化地图
//初始化地图
function initMap () {
  if (getUrlParam("isflag") == 230) {
    $("#ztcjgBTN").addClass("sec")
    $("#zbsxtBTN").removeAttr("class");
    $("#ztcjgWBTN").removeAttr("class")
    $("#wzyz").prop("checked", true);
  } else {
    $("#zbsxtBTN").addClass("sec")
    $("#ztcjgBTN").removeAttr("class");
    $("#ztcjgWBTN").removeAttr("class")
  }
  $("#zbsxt")[0].style.display = "";
  $("#ztcjg")[0].style.display = "none";
  // 百度地图API功能
  map = new BMap.Map("allmap"); // 创建Map实例
  map.centerAndZoom(new BMap.Point(Number(JWDNumArr[1]) - 0.012, Number(JWDNumArr[0]) - 0.011), 16); // 初始化地图,设置中心点坐标和地图级别

  var circle = new BMap.Circle(new BMap.Point(Number(JWDNumArr[1]), Number(JWDNumArr[0])), 1000, {
    fillOpacity: 0.3,
    strokeOpacity: 0.5,
    strokeWeight: 1,
    strokeStyle: 'dashed',
    strokeColor: 'blue'
  });

  map.addOverlay(circle);
  map.enableScrollWheelZoom(true);
  var myIcon = new BMap.Icon("/ditu/images/siteApprea.gif", new BMap.Size(35, 35)); // 设置图片偏移
  myIcon.setImageSize(new BMap.Size(35, 35));
  var marker = new BMap.Marker(new BMap.Point(Number(JWDNumArr[1]), Number(JWDNumArr[0])), {
    offset: new BMap.Size(0, 0),
    icon: myIcon
  });
  map.addOverlay(marker);
  spkinof2();
  // spkinof1();
  spkinof12();
  // var tileLayer = new BMap.TileLayer({
  //     isTransparentPng: true
  // });
  // tileLayer.getTilesUrl = function(tileCoord, zoom) {
  //     var x = tileCoord.x;
  //     var y = tileCoord.y;
  //     return 'http://11.15.237.126:8082/haidian_202008/tokenkpf44hglfu1ipa1clbibqor6lpcgf5ux/tms/1.0.0/haidian_202008/baidu/' + zoom + '/' + x + '/' + y + '.png';
  // }

  // map.addTileLayer(tileLayer);
  setTimeout(function () {
    map.centerAndZoom(new BMap.Point(Number(JWDNumArr[1]), Number(JWDNumArr[0])), 15); // 初始化地图,设置中心点坐标和地图级别

  }, 500)
  if (SHAPE != "") {
    bool = 1;
    var point = [];
    var coordinates = JSON.parse(SHAPE);
    $.each(coordinates.coordinates[0], function (i, lonlat) {
      lon = lonlat[0]; //经度坐标
      lat = lonlat[1]; //纬度坐标
      var m = {
        x: lon,
        y: lat
      }
      point[i] = new BMap.Point(m.x, m.y);
    });
    var polygon = new BMap.Polygon(point, {
      strokeColor: "red",
      strokeWeight: 3,
      strokeOpacity: 0.5,
      fillOpacity: 0.05
    });
    //创建多边形
    map.addOverlay(polygon)
  }
  $("#report").off("click").on("click", function () {
    layui.use('layer', function () {
      var layer = layui.layer;
      layer.open({
        type: 2,
        fixed: true,
        title: ['渣土车研判报告列表', 'font-size: 22px;color: rgb(49, 70, 89);'],
        closeBtn: 1,
        scrollbar: false,
        maxmin: false,
        content: '/vias_app/views/vias/urbanManagementLawEnforcement/chgzhf/reportOnlinePreview.html',
        area: ['1000px', '800px'],
        end: function () { }
      });
    });
  })
  // setTimeout(function() {
  //     if (GCMC != "") {
  //         var point = this.getUrlParam("point");
  //         point = point.split(",")
  //         console.log(point);
  //         $.ajax({
  //             type: 'get',
  //             dataType: "json",
  //             data: {
  //                 gcmc: GCMC
  //             },
  //             url: 'http://11.15.237.13:8013/VIAS/web/Accommodation/findByGcmc',
  //             success: function(data) {
  //                 if (data.length > 0) {
  //                     var start = new BMap.Point(Number(point[1]), Number(point[0]));
  //                     var end = new BMap.Point(data[0].LNG, data[0].LAT);
  //                     var opts1 = {
  //                         position: end, // 指定文本标注所在的地理位置
  //                         offset: new BMap.Size(-(data[0].XNMC.length * 13) / 2, 10) //设置文本偏移量
  //                     }
  //                     var label1 = new BMap.Label(data[0].XNMC, opts1); // 创建文本标注对象
  //                     label1.setStyle({
  //                         color: "red",
  //                         fontSize: "12px",
  //                         height: "20px",
  //                         lineHeight: "20px",
  //                         fontFamily: "微软雅黑"
  //                     });
  //                     map.addOverlay(label1);
  //                     var myIcon1 = new BMap.Icon("/ditu/images/ztc2.png", new BMap.Size(20, 20)); // 设置图片偏移
  //                     myIcon.setImageSize(new BMap.Size(20, 20));
  //                     var marker1 = new BMap.Marker(end, { offset: new BMap.Size(0, 0), icon: myIcon1 });
  //                     map.addOverlay(marker1); //
  //                     getGJinof(start, end, GJinof);
  //                 } else if (GCMC != null) {
  //                     var start = new BMap.Point(Number(point[1]), Number(point[0]));
  //                     var end = new BMap.Point(116.80933, 40.3221);

  //                     var xnmc = "密云区河南寨镇荆栗园村渣土消纳场所"
  //                     var opts1 = {
  //                         position: end, // 指定文本标注所在的地理位置
  //                         offset: new BMap.Size(-(xnmc.length * 13) / 2, 10) //设置文本偏移量
  //                     }
  //                     var label1 = new BMap.Label(xnmc, opts1); // 创建文本标注对象
  //                     label1.setStyle({
  //                         color: "red",
  //                         fontSize: "12px",
  //                         height: "20px",
  //                         lineHeight: "20px",
  //                         fontFamily: "微软雅黑"
  //                     });
  //                     map.addOverlay(label1);
  //                     var myIcon1 = new BMap.Icon("/ditu/images/ztc2.png", new BMap.Size(20, 20)); // 设置图片偏移
  //                     myIcon.setImageSize(new BMap.Size(20, 20));
  //                     var marker1 = new BMap.Marker(end, { offset: new BMap.Size(0, 0), icon: myIcon1 });
  //                     map.addOverlay(marker1); //
  //                     getGJinof(start, end, GJinof);
  //                 }
  //             }
  //         })
  //     }
  // }, 500)
}

function GJinof (data) {
  if (data.message == "ok") {
    var pts = data.results[0].path.split(",");
    var points = [];
    for (var i = 0; i < pts.length; i += 2) {
      points.push(new BMap.Point(pts[i], pts[i + 1]));
    }
    var polyline = new BMap.Polyline(points, { strokeWeight: 5, strokeColor: "red" });
    map.addOverlay(polyline);
  }
}

//一车一档详情
function showmotor (ssid, time, device_id, beginTime, obj, plateNo, plateColor) {

  var parma = '?ssid=' + encodeURIComponent(ssid) +
    '&time=' + encodeURIComponent(time) +
    '&deviceId=' + encodeURIComponent(device_id) +
    '&beginTime=' + encodeURIComponent(beginTime) +
    '&plateNo=' + encodeURIComponent(plateNo) +
    '&plateColor=' + encodeURIComponent(plateColor) +
    '&flag=' + encodeURIComponent(oneCarInfoStatus) +
    '&parentObj=detailObj';
  detailObj.index = obj;
  detailObj.plateColor = plateColor;
  layui.use('layer', function () {
    var layer = layui.layer;
    layer.open({
      type: 2,
      fixed: true,
      title: ['一车一档详情', 'font-size: 22px;color: rgb(49, 70, 89);'],
      closeBtn: 1,
      scrollbar: false,
      maxmin: false,
      content: '/vias_app/views/vias/snapshot/ztc/oneCarToInfo.html' + parma,
      area: ['100%', '100%'],
      end: function () {
        // 暂时不用
      }
    });
  });
}

function spkinof1 () {
  $.ajax({
    type: 'get',
    dataType: "JSON",
    contentType: "application/json",
    data: {
      id: getUrlParam("devid")
    },
    url: GDUrl + "/VIAS/web/snapshot/WorkSite/queryInfoById",
    success: function (data) {
      // console.log(data)
      $.each(data, function (i, row) {
        detailObj.dwData1.push(row);
        if (i == data.length - 1) {
          detailObj.ztcdevid += row.DEVICE_ID;
        } else {
          detailObj.ztcdevid += row.DEVICE_ID + ",";
        }
      })
      spkinof3();
    }
  });
}

function spkinof12 () {
  $.ajax({
    type: 'get',
    dataType: "JSON",
    contentType: "application/json",
    data: {
      GDID: getUrlParam("devid")
    },
    //siteUrl_port
    url: siteUrl_port + "/VIAS/web/site/selectINLOOKByGDID",
    success: function (data) {
      // console.log(data)
      var num = 0;
      var _html = "";
      if (data !== null && data.length > 0) {
        $.each(data, function (i, rows) {
          num += 1;
          _html += `<div class="spl_res_item"  onclick="bayonet1(this);" devname="${rows.SBMC}"  devid="${rows.SBBH}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon"><img src="/ditu/images/qji2.png"><img src="/ditu/images/sp_licon3.png"></div><div class="spl_res_txt" ><h4  title="${rows.SBMC}">${rows.SBMC}</h4><p>微卡口</p><p style="float: left">${rows.SSJD}</p><p id=\"${rows.SBBH}\" style=\"float: right\">未获取到</p></div></div>`;

          var code = rows.SBBH;

          // var obj = "";

          $.ajax({
            type: 'get',
            dataType: "json",
            data: {
              code: code,
            },
            url: "http://11.15.238.107:10000/api/v1/device/channellist",
            success: function (info) {
              // console.log("====================================================")
              // console.log(info)
              // console.log("====================================================")
              if (i <= 10) {
                if (info.ChannelList[0].Status == "OFF") {
                  $("#" + code).text("离线")
                  // obj = "<p style=\"float: right\">离线</p>";
                  // $("#"+code).append("<p style=\"float: right\">离线</p>")
                } else {
                  $("#" + code).text("在线")
                  // obj = "<p style=\"float: right\">在线</p>";
                  // $("#"+code).append("<p style=\"float: right\">在线</p>")
                }
              }
            },
            error: function () { //请求的失败的返回的方法
              // obj = "<p style=\"float: right\">未获取到</p>";
              // $("#"+code).append("<p style=\"float: right\">未获取到</p>")
            }
          });

          // $("#"+code).append(obj)

        })
        $("#kknum2").text("(" + num + ")");
        $("#total2").text(num);
        $("#sql_con2").empty();
        $("#spl_con2").html(_html);
      } else {
        $(".gdxx_btn2").attr("style", "display:none;"); //隐藏div
        $("#spl_res2").attr("style", "display:none;"); //隐藏div
      }
    }
  });
}

function spkinof3 () {
  var point = this.getUrlParam("point");
  point = point.split(",");
  $.ajax({
    type: "get",
    dataType: "json",
    // async: false,
    data: {
      httpurl: "roadseg?index=dugis_ut_awkk&type=default&location=" + point[0] + "," + point[1] + "&radius=" + 1000 + "&output=json&page_size=10000"
    },
    // url: "http://11.16.127.79:5013/VIAS/web/snapshot/baidu/CircularSearch",
    url: 'http://11.16.127.79:5013/VIAS/web/snapshot/baidu/CircularSearch',
    success: function (data) {
      if (data.status == 0) {
        data.results.reverse();
        var data1 = unique(data.results);

        var count = 0;

        $.each(data1, function (i, row1) {
          var num = 0;
          if (IsBXKK(row1.devId) == 0) {
            if (row1.devName.indexOf("JK") < 0 && row1.devName.indexOf("IPC") < 0) {
              if (detailObj.dwData1.length > 0) {

                $.each(detailObj.dwData1, function (i, row) {
                  if (row1.devId == row.DEVICE_ID) {
                    num = 1;
                    row1.bayonet = Number(row1.bayonet) + 2;
                    detailObj.devid.unshift(row1);
                  } else {
                    count += 1;
                  }
                })
                if (num != 1) {
                  detailObj.devid.push(row1);
                } else {
                  count += 1;
                }
              } else {
                detailObj.devid.push(row1);
              }
            } else {
              count += 1;
            }
          } else {
            count += 1;
          }
        })

        // console.log("===================================================")
        // console.log(count)
        // console.log("===================================================")
      }
      //展示数据
      spkin();
    }
  })
}

function getDateStr (AddDayCount) {
  var dd = new Date();
  dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
  var y = dd.getFullYear();
  var m = (dd.getMonth() + 1) < 10 ? "0" + (dd.getMonth() + 1) : (dd.getMonth() + 1); //获取当前月份的日期，不足10补0
  var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate(); //获取当前几号，不足10补0
  return y + "-" + m + "-" + d;
}

// function spkin() {
//     var num = 0;
//     var _html = "";
//     var dwData = JSON.parse(localStorage.getItem("dwData"))
//     var point = getUrlParam("point");
//     var pointArr = point.split(",")
//     var circle = new BMap.Circle(new BMap.Point(pointArr[1], pointArr[0]), 1500, {
//         strokeColor: "blue",
//         strokeWeight: 2,
//         strokeOpacity: 0.5
//     });
//     $.each(dwData, function (i, rows) {
//         if (BMapLib.GeoUtils.isPointInCircle(new BMap.Point(rows.coordinates[0], rows.coordinates[1]), circle)) {
//
//             if (rows.bayonet == 0) {
//                 num += 1;
//                 _html += `<div class="spl_res_item"  onclick="bayonet(this);" devname="${rows.devName}"  devid="${rows.devId}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon"><img src="/ditu/images/qji2.png"><img src="/ditu/images/sp_licon3.png"></div><div class="spl_res_txt"><h4  title="${rows.devName}">${rows.devName}</h4><p>非微卡口</p><p style="float: left">${rows.streetname}</p></div></div>`;
//             } else if (rows.bayonet == 1) {
//                 _html += `<div class="spl_res_item"  onclick="bayonetwkk(this);" devname="${rows.devName}" devid="${rows.devId}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon" ><img src="/ditu/images/wkk4.png"><img src="/ditu/images/sp_licon3.png"></div><div class="spl_res_txt"><h4  title="${rows.devName}">${rows.devName}</h4><p>微卡口</p><p style="float: left">${rows.streetname}</p></div></div>`;
//                 num += 1;
//             } else if (rows.bayonet == 2) {
//                 num += 1;
//                 _html += `<div class="spl_res_item"  onclick="bayonet(this);" devname="${rows.devName}"  devid="${rows.devId}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon"><img src="/ditu/images/qji2.png"><img src="/ditu/images/sp_licon3.png"></div><div class="spl_res_txt"><h4  title="${rows.devName}" style="    font-weight: bold;
//             font-size: 24px;">${rows.devName}</h4><p>非微卡口(出入口)</p><p style="float: left">${rows.streetname}</p></div></div>`;
//
//             } else if (rows.bayonet == 3) {
//                 _html += `<div class="spl_res_item"  onclick="bayonetwkk(this);" devname="${rows.devName}" devid="${rows.devId}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon" ><img src="/ditu/images/wkk4.png"><img src="/ditu/images/sp_licon3.png"></div><div class="spl_res_txt"><h4 style="    font-weight: bold;
//             font-size: 24px;" title="${rows.devName}">${rows.devName}</h4><p>微卡口(出入口)</p><p style="float: left">${rows.streetname}</p></div></div>`;
//                 num += 1;
//             }
//
//
//             var code = rows.devId
//
//             $.ajax({
//                 type: 'get',
//                 dataType: "json",
//                 data: {
//                     code: code,
//                 },
//                 url: "http://11.15.235.161:10005/api/v1/device/channellist",
//                 success: function (data) {
//                     if (data.ChannelList[0].Status == "OFF" && num <= 10) {
//                         console.log(data)
//                         $(".spl_res_txt").append("<p style=\"float: right\">离线</p>")
//                     }
//
//                 }
//             });
//
//         }
//     })
//     $("#kknum").text("(" + num + ")");
//     $("#total1").text(num);
//     $("#sql_con").empty();
//     $("#spl_con").html(_html);
// }

var wbkkDevId = [];

function spkin () {

  var num = 0;
  var _html = "";
  $.each(detailObj.devid, function (i, rows) {
    if (rows.bayonet == 0) {
      _html += `<div class="spl_res_item"  onclick="bayonet(this);" devname="${rows.devName}"  devid="${rows.devId}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon"><img src="/ditu/images/qji2.png"><img src="/ditu/images/sp_licon3.png"></div><div class="spl_res_txt"><h4  title="${rows.devName}">${rows.devName}</h4><p>非微卡口</p><p style=\"float: left\">${rows.streetname}</p><p id="${rows.devId}" style=\"float: right\">未获取到</p></div></div>`;
      num += 1;
      wbkkDevId.push(rows.devId)
    } else if (rows.bayonet == 1) {
      _html += `<div class="spl_res_item"  onclick="bayonetwkk(this);" devname="${rows.devName}" devid="${rows.devId}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon" ><img src="/ditu/images/wkk4.png"><img src="/ditu/images/sp_licon3.png"></div><div class="spl_res_txt"><h4  title="${rows.devName}">${rows.devName}</h4><p>微卡口</p><p  style=\"float: left\">${rows.streetname}</p><p id="${rows.devId}" style=\"float: right\">未获取到</p></div></div>`;
      num += 1;
      wbkkDevId.push(rows.devId)
    } else if (rows.bayonet == 2) {
      num += 1;
      wbkkDevId.push(rows.devId)
      _html += `<div class="spl_res_item"  onclick="bayonet(this);" devname="${rows.devName}"  devid="${rows.devId}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon"><img src="/ditu/images/qji2.png"><img src="/ditu/images/sp_licon3.png"></div><div class="spl_res_txt"><h4  title="${rows.devName}" style="    font-weight: bold;
            font-size: 24px;">${rows.devName}</h4><p>非微卡口(出入口)</p><p  style=\"float: left\">${rows.streetname}</p><p id="${rows.devId}" style=\"float: right\">未获取到</p></div></div>`;

    } else if (rows.bayonet == 3) {
      _html += `<div class="spl_res_item"  onclick="bayonetwkk(this);" devname="${rows.devName}" devid="${rows.devId}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon" ><img src="/ditu/images/wkk4.png"><img src="/ditu/images/sp_licon3.png"></div><div class="spl_res_txt"><h4 style="    font-weight: bold;
            font-size: 24px;" title="${rows.devName}">${rows.devName}</h4><p>微卡口(出入口)</p><p style=\"float: left\">${rows.streetname}</p><p id="${rows.devId}" style=\"float: right\">未获取到</p></div></div>`;
      num += 1;
      wbkkDevId.push(rows.devId)
    }
    var code = rows.devId
    // console.log("加载initmap"+num);

    $("#kknum").text("(" + num + ")");
    $("#total1").text(num);
    $("#sql_con").empty();
    $("#spl_con").html(_html);

    // var obj = "<p id=\"sbzt\" style=\"float: right\">未获取到</p>";
    // $("#"+code).append(obj)
  })

  this.getWBKKStatus();

}

function getWBKKStatus () {
  $.each(wbkkDevId, function (i, rows) {
    if (i < 10) {
      $.ajax({
        type: 'get',
        dataType: "json",
        timeout: 2500,
        data: {
          code: rows,
        },
        // url: "http://11.15.235.161:10005/api/v1/device/channellist",
        url: "http://11.16.39.158:10000/api/v1/device/channellist",
        success: function (info) {
          if (info.ChannelCount != 0) {
            if (info.ChannelList[0].Status == undefined || info.ChannelList[0].Status == "OFF") {
              $("#" + rows).text("离线")
              // obj = "<p style=\"float: right\">离线</p>";
              // $("#"+code).append("<p style=\"float: right\">离线</p>")
            } else {
              $("#" + rows).text("在线")
              // obj = "<p style=\"float: right\">在线</p>";
              // $("#"+code).append("<p style=\"float: right\">在线</p>")
            }
          }

        },
        error: function () { //请求的失败的返回的方法
          // obj = "<p style=\"float: right\">未获取到</p>";
          // $("#"+code).append("<p style=\"float: right\">未获取到</p>")
        }
      });
    } else if (i < 30 && i >= 10) {
      $("#" + rows).text("在线")
    }

  })


}


// function spk() {
//     var devid = "";
//
//     if (detailObj.bool == 1 && detailObj.bool2 == 0) {
//         alert(1)
//         $(".gdxx_btn").css("right", "0rem");
//         $(".gdxx_btn2").css("right", "0rem");
//         $(".gdxx_btn3").css("right", "0rem");
//         $("#spl_res1").css("right", "-4.5rem");
//         $("#spl_res2").css("right", "-4.5rem");
//         $("#spl_res3").css("right", "-4.5rem");
//         detailObj.bool = 0;
//     } else if (detailObj.bool == 0 && detailObj.bool2 == 0) {
//         alert(2)
//         $(".gdxx_btn").css("right", "4rem");
//         $(".gdxx_btn2").css("right", "4rem");
//         $(".gdxx_btn3").css("right", "4rem");
//
//         $("#spl_res1").css("right", "0rem");
//         $("#spl_res2").css("right", "-4.5rem");
//         $("#spl_res3").css("right", "-4.5rem");
//         detailObj.bool = 1;
//     } else if (detailObj.bool == 1 && detailObj.bool2 == 1) {
//         alert(3)
//         $(".gdxx_btn").css("right", "0rem");
//         $(".gdxx_btn2").css("right", "0rem");
//         $(".gdxx_btn3").css("right", "0rem");
//         $("#spl_res1").css("right", "-4.5rem");
//         $("#spl_res2").css("right", "-4.5rem");
//         $("#spl_res3").css("right", "-4.5rem");
//         detailObj.bool = 0;
//         detailObj.bool2 = 0;
//         detailObj.bool3 = 0;
//     } else if (detailObj.bool == 0 && detailObj.bool2 == 1) {
//         alert(4)
//         $(".gdxx_btn").css("right", "4rem");
//         $(".gdxx_btn2").css("right", "4rem");
//         $(".gdxx_btn3").css("right", "4rem");
//         $("#spl_res1").css("right", "0rem");
//         $("#spl_res2").css("right", "-4.5rem");
//         $("#spl_res3").css("right", "-4.5rem");
//         detailObj.bool2 = 0;
//         detailObj.bool3 = 0;
//         detailObj.bool = 1;
//     }
// }

function spk () {
  if (detailObj.bool == 0) {
    $(".gdxx_btn").css("right", "4rem");
    $(".gdxx_btn2").css("right", "4rem");
    $(".gdxx_btn3").css("right", "4rem");
    $("#spl_res1").css("right", "0rem");
    $("#spl_res2").css("right", "-4.5rem");
    $("#spl_res3").css("right", "-4.5rem");
    detailObj.bool = 1;
    detailObj.bool2 = 0;
    detailObj.bool3 = 0;
  } else {
    $(".gdxx_btn").css("right", "0rem");
    $(".gdxx_btn2").css("right", "0rem");
    $(".gdxx_btn3").css("right", "0rem");
    $("#spl_res1").css("right", "-4.5rem");
    $("#spl_res2").css("right", "-4.5rem");
    $("#spl_res3").css("right", "-4.5rem");
    detailObj.bool = 0;
  }
}

// function spk2() {
//     var devid = "";
//
//     if (detailObj.bool == 1 && detailObj.bool2 == 0) {
//         alert(1)
//         $(".gdxx_btn").css("right", "0rem");
//         $(".gdxx_btn2").css("right", "0rem");
//         $(".gdxx_btn3").css("right", "0rem");
//         $("#spl_res1").css("right", "-4.5rem");
//         $("#spl_res2").css("right", "-4.5rem");
//         $("#spl_res3").css("right", "-4.5rem");
//         detailObj.bool2 = 0;
//     } else if (detailObj.bool == 0 && detailObj.bool2 == 0) {
//         alert(2)
//         $(".gdxx_btn").css("right", "4rem");
//         $(".gdxx_btn2").css("right", "4rem");
//         $(".gdxx_btn3").css("right", "4rem");
//
//         $("#spl_res2").css("right", "0rem");
//         $("#spl_res1").css("right", "-4.5rem");
//         $("#spl_res3").css("right", "-4.5rem");
//         detailObj.bool2 = 1;
//     } else if (detailObj.bool == 1 && detailObj.bool2 == 1) {
//         alert(3)
//         $(".gdxx_btn").css("right", "0rem");
//         $(".gdxx_btn2").css("right", "0rem");
//         $(".gdxx_btn3").css("right", "0rem");
//         $("#spl_res1").css("right", "-4.5rem");
//         $("#spl_res2").css("right", "-4.5rem");
//         $("#spl_res3").css("right", "-4.5rem");
//         detailObj.bool = 0;
//         detailObj.bool2 = 0;
//         detailObj.bool3 = 0;
//     } else if (detailObj.bool2 == 1) {
//         alert(4)
//         $(".gdxx_btn").css("right", "0rem");
//         $(".gdxx_btn2").css("right", "0rem");
//         $(".gdxx_btn3").css("right", "0rem");
//         $("#spl_res2").css("right", "-4.5rem");
//         $("#spl_res1").css("right", "-4.5rem");
//         $("#spl_res3").css("right", "-4.5rem");
//         detailObj.bool2 = 0;
//     }
// }

function spk2 () {
  if (detailObj.bool2 == 0) {
    $(".gdxx_btn").css("right", "4rem");
    $(".gdxx_btn2").css("right", "4rem");
    $(".gdxx_btn3").css("right", "4rem");
    $("#spl_res2").css("right", "0rem");
    $("#spl_res1").css("right", "-4.5rem");
    $("#spl_res3").css("right", "-4.5rem");
    detailObj.bool2 = 1;
    detailObj.bool = 0;
    detailObj.bool3 = 0;
  } else {
    $(".gdxx_btn").css("right", "0rem");
    $(".gdxx_btn2").css("right", "0rem");
    $(".gdxx_btn3").css("right", "0rem");
    $("#spl_res1").css("right", "-4.5rem");
    $("#spl_res2").css("right", "-4.5rem");
    $("#spl_res3").css("right", "-4.5rem");
    detailObj.bool2 = 0;
  }
}

// function spk3() {
//     var devid = "";
//
//     if (detailObj.bool3 == 1) {
//         alert(1)
//         $(".gdxx_btn").css("right", "0rem");
//         $(".gdxx_btn2").css("right", "0rem");
//         $(".gdxx_btn3").css("right", "0rem");
//         $("#spl_res1").css("right", "-4.5rem");
//         $("#spl_res2").css("right", "-4.5rem");
//         $("#spl_res3").css("right", "-4.5rem");
//         detailObj.bool3 = 0;
//     } else if (detailObj.bool == 0 && detailObj.bool2 == 0) {
//         alert(2)
//         $(".gdxx_btn").css("right", "4rem");
//         $(".gdxx_btn2").css("right", "4rem");
//         $(".gdxx_btn3").css("right", "4rem");
//
//         $("#spl_res1").css("right", "0rem");
//         $("#spl_res2").css("right", "-4.5rem");
//         $("#spl_res3").css("right", "-4.5rem");
//         detailObj.bool3 = 1;
//     } else if (detailObj.bool == 1 && detailObj.bool2 == 1) {
//         alert(3)
//         $(".gdxx_btn").css("right", "0rem");
//         $(".gdxx_btn2").css("right", "0rem");
//         $(".gdxx_btn3").css("right", "0rem");
//         $("#spl_res1").css("right", "-4.5rem");
//         $("#spl_res2").css("right", "-4.5rem");
//         $("#spl_res3").css("right", "-4.5rem");
//         detailObj.bool = 0;
//         detailObj.bool2 = 0;
//         detailObj.bool3 = 0;
//     } else if (detailObj.bool == 0 && detailObj.bool2 == 1) {
//         alert(4)
//         $(".gdxx_btn").css("right", "4rem");
//         $(".gdxx_btn2").css("right", "4rem");
//         $(".gdxx_btn3").css("right", "4rem");
//         $("#spl_res1").css("right", "0rem");
//         $("#spl_res2").css("right", "-4.5rem");
//         $("#spl_res3").css("right", "-4.5rem");
//         detailObj.bool2 = 0;
//         detailObj.bool = 0;
//         detailObj.bool3 = 1;
//     }
// }

function spk3 () {
  if (detailObj.bool3 == 0) {
    $(".gdxx_btn").css("right", "4rem");
    $(".gdxx_btn2").css("right", "4rem");
    $(".gdxx_btn3").css("right", "4rem");
    $("#spl_res3").css("right", "0rem");
    $("#spl_res1").css("right", "-4.5rem");
    $("#spl_res2").css("right", "-4.5rem");
    detailObj.bool3 = 1;
    detailObj.bool = 0;
    detailObj.bool2 = 0;
    /*查询事件数据*/
    funcData();
  } else {
    $(".gdxx_btn").css("right", "0rem");
    $(".gdxx_btn2").css("right", "0rem");
    $(".gdxx_btn3").css("right", "0rem");
    $("#spl_res1").css("right", "-4.5rem");
    $("#spl_res2").css("right", "-4.5rem");
    $("#spl_res3").css("right", "-4.5rem");
    detailObj.bool3 = 0;
  }
}

function funcData () {
  var devid = getUrlParam("devid");
  $.ajax({
    type: "get",
    url: siteUrl_port + "/VIAS/web/site/details/selectByDevid",
    data: {
      devid: devid
    },
    dataType: "json",
    success: function (data) {
      $(".newslist01").children().remove();
      $.each(data.list, function (i, row) {
        $(".newslist01").append("<li><a>" + row.ROW_ID + ".&nbsp;&nbsp;" + row.CONTENT + "</a><span class=\"time\">&nbsp;&nbsp;" + dateFtt("yyyy-MM-dd hh:mm:ss", new Date(row.DATATIME)) + "</span></li>");
      })
    }
  });
}

function confirmContentSubmit () {
  var content = $("#contentSJ").val();
  var devid = getUrlParam("devid");
  if (content == "") {
    layer.msg('请输入事件!');
    return;
  } else {
    $("#confirmContentSubmit").attr({ "disabled": "disabled" });
    var parm = {
      devid: devid,
      content: content,
    }
    $.ajax({
      type: "post",
      url: siteUrl_port + "/VIAS/web/site/details/addDetail",
      data: JSON.stringify(parm),
      contentType: 'application/json',
      dataType: "json",
      success: function (data) {
        if (data.success) {
          funcData();
          clenInput()
          $("#confirmContentSubmit").removeAttr("disabled");
        }
      }
    });
  }
}

function clenInput () {
  $("#contentSJ").val("");
}

function getUrlParam (key, url) {
  var href = url || window.location.href;
  var url = href.split("?");
  if (url.length <= 1) {
    return "";
  }
  var params = url[1].split("&");

  for (var i = 0; i < params.length; i++) {
    var param = params[i].split("=");
    if (key == param[0]) {
      if (url[2] != undefined) {
        return decodeURIComponent(param[1] + '?' + url[2]);
      }
      return decodeURIComponent(param[1]);
    }
  }
}

function dateFtt (fmt, date) { //author: meizz
  var o = {
    "M+": date.getMonth() + 1,                 //月份
    "d+": date.getDate(),                    //日
    "h+": date.getHours(),                   //小时
    "m+": date.getMinutes(),                 //分
    "s+": date.getSeconds(),                 //秒
    "q+": Math.floor((date.getMonth() + 3) / 3), //季度
    "S": date.getMilliseconds()             //毫秒
  };
  if (/(y+)/.test(fmt))
    fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt))
      fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  return fmt;
}

//点击选择按钮选择车辆
function countCar () {
  for (var i = 0; i < $('input:checkbox[name=xzsjCheck]:checked').length; i++) {
    $('input:checkbox[name=xzsjCheck]:checked')[i].checked = false
  }
  if (clickCarCount == 0) {
    clickCarCount = 1;
    $(".xzsjCheck").css("display", "block")
    $(".sjcyYN").css("pointer-events", "none")
    $(".xuanzeBtn").css("display", "inline-block")
  } else {
    clickCarCount = 0;
    $(".xzsjCheck").css("display", "none")
    $(".sjcyYN").css("pointer-events", "auto")
    $(".xuanzeBtn").css("display", "none")
  }

}

function getCookie (cname) {
  var name = cname + "=";
  var decodedCookie = decodeURIComponent(document.cookie);
  var ca = decodedCookie.split(';');
  for (var i = 0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    }
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length);
    }
  }
  return "";
}

//确定提交车辆数据
function submitCar () {
  var username = window.sessionStorage.getItem("user");
  var czcIds = "";
  var nums = $('input:checkbox[name=xzsjCheck]:checked').length
  $('input:checkbox[name=xzsjCheck]:checked').each(function (i) {
    if (0 == i) {
      czcIds = $(this).attr("id");
    } else {
      czcIds += ("," + $(this).attr("id"));
    }
  });
  if (nums > 3) {
    layer.msg('<span style="font-size:20px">此处限定选择三辆车,请重新选择！</span>', { icon: 5, time: 2000, shift: 5 })
  }
  if (nums < 1) {
    layer.msg('<span style="font-size:20px">请选择车辆！</span>', { icon: 5, time: 2000, shift: 5 })
  }

  if (nums >= 1 && nums <= 3) {

    $.ajax({
      type: 'get',
      dataType: "text",
      data: {
        ids: czcIds,
        street: streetname,
        siteAddress: projectAddress,
        username: username,
        caseFlag: caseFlag,
        centralLon: umgLon,
        centralLat: umgLat
      },
      url: "http://11.16.125.16:5599/vias/push/saveData",
      // url: ZTCUrl + url,
      success: function (data) {
        if (data != '') {
          window.open("/vias_app/views/vias/UrbanManagement/eventListAndPush.html?caseNum=" + data);
        }
      }
    })
    clickCarCount = 0;
    $(".xzsjCheck").css("display", "none")
    $(".sjcyYN").css("pointer-events", "auto")
    $(".xuanzeBtn").css("display", "none")
  }
}

//主体信息查询 内监管 外监管 zhuti
function searchInfo (page, type) {
  var souID = "210,200,230";
  var iszyz = '';
  var btn = '';
  if (getUrlParam("isflag") == 230) {
    souID = "230";
    iszyz = 1;
  }
  // showNoPlate_flag = false
  if (type === 1) {
    // url = "/VIAS/web/ztc/ztcjgFindByMuckTruck"
    deviceBase = getUrlParam("YWBM") + "," + getUrlParam("devid")
    btn = "<button id='choseBtn' onclick='countCar()'>选择</button><button id='submitBtn' onclick='submitCar()'>确定</button>";
    // showNoPlate_flag = true
  } else if (type === 2) {
    // url = "/VIAS/web/ztc/ztcjgFindByMuckTruck"
    deviceBase = deviceIds
  } else if (type === 3) {
    deviceBase = crkFlag
    // showNoPlate_flag = true
  }

  $.ajax({
    type: 'get',
    dataType: "json",
    data: {
      page: page, //当前页码号
      rows: 6, //每页显示六条
      deviceId: deviceBase,
      isZYZ: iszyz == '' ? ids : iszyz, //查询条件
      isWSG: isWSG, //未苫盖 1选中
      labelType: labelType,
      plateNo: $("#plateNo").val(),
      sourceID: souID,
      JXX: JXX,
      showNoPlate: showNoPlate_flag,
      beginTime: $("#beginTime").val(), //开始日期
      endTime: $("#endTime").val(), //结束日期
    },
    url: ZTCUrl + "/VIAS/web/ztc/findByMuckTruckLeaderUse",
    // url: ZTCUrl + url,
    success: function (data) {
      if (data.rows.length <= 0) {
        $.ajax({
          type: 'get',
          dataType: "json",
          data: {
            page: page, //当前页码号
            rows: 6, //每页显示六条
            deviceId: getUrlParam("devid"),
            isZYZ: iszyz == '' ? ids : iszyz, //查询条件
            // isWSG: isWSG, //未苫盖 1选中
            labelType: labelType,
            plateNo: $("#plateNo").val(),
            sourceID: souID,
            JXX: JXX,
            beginTime: $("#beginTime").val(), //开始日期
            endTime: $("#endTime").val(), //结束日期
          },
          url: ZTCUrl + "/VIAS/web/ztc/findByMuckTruckLeaderUse",
          // url: ZTCUrl + url,
          success: function (data2) {
            data = data2
          }
        })
      }
      $("#ztcjgInfo").empty();
      var iszyz;
      $("#total").empty();
      $("#pageNum").empty();
      $("#btnChack").empty();
      detailObj.dataArr = data.rows;
      total = data.totalPages
      if (btn != "") {
        $("#btnChack").html(btn)
      }

      $("#pageNum").text("共" + data.totalPages + "页")
      $("#total").text('渣土车共计' + data.total + '车次') //，违规渣土车47车次（未备案46车次，未苫盖1车次，未清洗0车次，有遮挡15车次）'
      for (var i = 0; i < data.rows.length; i++) {
        $.ajax({
          async: false,
          type: 'get',
          dataType: 'json',
          data: {
            ch: data.rows[i].PLATE_NO, //车牌号
            passTime: data.rows[i].PASS_TIME //经过时间
          },
          url: ZTCUrl + "/VIAS/web/ztc/findMotorVehicleZYZBycph",
          success: function (zyz) {
            if (zyz.length > 0) {
              iszyz = 20
            } else {
              iszyz = 16
            }
          }
        })
        var isPush = '';
        $.ajax({
          async: false,
          type: 'get',
          dataType: 'json',
          data: {
            SSID: data.rows[i].SS_ID, //车牌号
            passTime: data.rows[i].PASS_TIME //经过时间
          },
          //url: ZTCUrl + "/VIAS/web/ztc/findMotorVehicleZYZBycph",
          url: "http://11.16.125.16:5599/VIAS/web/UrbanManagement/isSaveEvent",
          success: function (data) {
            console.log(data)
            if (data.length > 0) {
              isPush = "已移送"
              $.each(data, function (i, rows) {
                if (rows.CASESTATE == "已结案") {
                  isPush += "已处罚"
                }
              })
            }
          }
        })
        choseColor(data.rows[i].VEHICLE_COLOR)
        var iszyzText;
        var hgText;
        var plateNo = data.rows[i].PLATE_NO;
        var carData = data.rows[i];
        var ycchp = false;
        var wsg = false;
        if (carData.IS_COVERED === '1') {
          ycchp = true;
        }
        if (carData.IS_COVERPANEL === '1') {
          wsg = true;
        }
        if (iszyz === 20) {
          iszyzText = '合格';
          hgText = "<span class='ztcjg_hg'>合格</span></div>"
          if (ycchp) {
            iszyzText = '异常号牌';
            hgText = "<span class='ztcjg_wg'>违规</span></div>"
          }
          if (!oneCarInfoStatus && wsg) {
            iszyzText = '未苫盖';
            hgText = "<span class='ztcjg_wg'>违规</span></div>"
          }
        } else if (iszyz === 16) {
          // if (caseFlag == '3') {
          //     iszyz = 99
          //     iszyzText = '未识别';
          //     hgText = "<span class='ztcjg_wg'>违规</span></div>"
          // } else if(caseFlag == '2'){
          //     iszyzText = '无准运证';
          //     hgText = "<span class='ztcjg_wg'>违规</span></div>"
          // } else if(caseFlag == '1') {
          //     iszyzText = '异常号牌';
          //     hgText = "<span class='ztcjg_wg'>违规</span></div>"
          // } else if(caseFlag == '5') {
          //     iszyzText = '闯限行';
          //     hgText = "<span class='ztcjg_wg'>违规</span></div>"
          // } else if(caseFlag == '4') {
          //     iszyzText = '未苫盖';
          //     hgText = "<span class='ztcjg_wg'>违规</span></div>"
          // } else if(ycchp) {
          //     iszyzText = '异常号牌';
          //     hgText = "<span class='ztcjg_wg'>违规</span></div>"
          // } else if(wsg) {
          //     iszyzText = '未苫盖、无准运证';
          //     hgText = "<span class='ztcjg_wg'>违规</span></div>"
          // }else {
          //     iszyzText = '无准运证';
          //     hgText = "<span class='ztcjg_wg'>违规</span></div>"
          // }

          iszyzText = '无准运证';
          hgText = "<span class='ztcjg_wg'>违规</span></div>"
          if (caseFlag == '1') {
            iszyzText += '、异常号牌';
          } else if (caseFlag == '5') {
            iszyzText += '、闯限行';
          } else if (caseFlag == '4') {
            iszyzText += '、未苫盖';
          }
          if (ycchp && caseFlag != '1') {
            iszyzText += '、异常号牌';
          }
          if (!oneCarInfoStatus && caseFlag != '4' && wsg) {
            iszyzText += '、未苫盖';
          }
        } else {
          iszyzText = '未识别';
          hgText = "<span class='ztcjg_wg'>违规</span></div>"
        }
        //  else if (labels.substring(0, 1) === 1) {
        //     iszyzText = '未苫盖';
        //     hgText = "<span class='ztcjg_wg'>违规</span></div>"
        // } else if (labels.substring(0, 1) === 3) {
        //     iszyzText = '异常号牌';
        //     hgText = "<span class='ztcjg_wg'>违规</span></div>"
        // } else if (labels.substring(0, 1) === 4) {
        //     iszyzText = '仅限行';
        //     hgText = "<span class='ztcjg_wg'>违规</span></div>"
        // }





        var begintimee = getDateStr(-10) + " 00:00:00";

        if (plateNo === '00000000') {
          plateNo = '车牌无法识别';
        }
        var info = "<div class='ztcjg_r_item'><div class='ztcjg_ritem_top'>" +

          "<h4><span>" + iszyzText + "</span>" + data.rows[i].PASS_TIME + "</h4>" +
          "<h4><span>" + isPush + "</span></h4>" +
          "<img src='/ditu/images/ztcjg_icon" + iszyz + ".png'></img></div>" +
          "<div class='ztcjg_ritem_img'>" +
          "<input id='" + data.rows[i].SS_ID + "' type='checkbox' class='xzsjCheck' name='xzsjCheck' value='" + data.rows[i].PASS_TIME + "'>" +
          "<img src='" + data.rows[i].STORAGE_URL1 + "'>" + hgText + "" +
          "<div class='ztcjg_ritem_txt'><img src='/ditu/images/ztcjg_icon21.png'>" +
          "<b>" + plateNo + "</b>" +
          "<span>" + carColor + "色" + data.rows[i].VEHICLE_SUB_BRAND + "</span>" +
          "<span class='xiangqingSty'" +
          `onclick="showmotor('${data.rows[i].SS_ID}','${data.rows[i].PASS_TIME}','${data.rows[i].DEVICE_ID}','${begintimee}','${i}','${data.rows[i].PLATE_NO}','${data.rows[i].PLATE_COLOR}')">详情</span>`;

        if (type == 2) {
          info += "<p>" + (data.rows[i].SS_APE_NAME != "undefined" ? data.rows[i].SS_APE_NAME : $("#GD_total").text()) + "出现</p></div></div>"
        }
        $("#ztcjgInfo").append(info);
      }
    }
  })
}

function getSiteDeviceId (siteId) {
  $.ajax({
    type: 'get',
    dataType: "json",
    data: {
      siteId: siteId
    },
    url: ZTCUrl + "/VIAS/web/muckTruck/clajfk/getDevieIdBySiteId",
    // url: "http://localhost:8013/VIAS/web/muckTruck/clajfk/getDevieIdBySiteId",
    success: function (data) {
      if (data != null) {
        crkFlag = data.deviceId
      }
    }
  })
}

function initDeviceId () {
  $.ajax({
    type: 'get',
    dataType: "json",
    data: {
      httpurl: '/cloudSearch/search/nearby?location=' + JWDNumArr[1] + ',' + JWDNumArr[0] + '&radius=1000&table=awkk1&page_number=1&page_size=1000&data_type=2'
    },
    url: 'http://11.16.127.79:5013/VIAS/web/snapshot/baidu/CircularSearch',
    success: function (data) {
      for (i in data.data.list) {
        deviceIds = deviceIds + data.data.list[i].devId + ","
      }
      deviceIds = deviceIds.substring(0, deviceIds.length - 1)
    }
  })
}

function initCondition () {
  // var today;
  var endDay;
  // today = new Date().pattern("yyyy-MM-dd 00:00:00");
  var today = new Date();
  endDay = new Date();
  if (getUrlParam("isflag") == 230) {
    layui.use('laydate', function () {
      var laydate = layui.laydate;
      laydate.render({
        elem: '#beginTime',
        type: 'datetime',
        theme: '#2180d4',
        value: new Date(today.setDate((new Date().getDate() - 7))).Format("yyyy-MM-dd 00:00:00"),
        btns: ['now', 'confirm'],
        max: new Date().pattern("yyyy-MM-dd HH:mm:ss"),
        done: function (value, date) {
          var starttime = value.replace(/-/g, "/"),
            d1 = (new Date(starttime)).getTime(),
            endtime = ($("#endTime").val()).replace(/-/g, "/"),
            d2 = (new Date(endtime)).getTime();
          if (d1 > d2) {
            $("#endTime").val('');
          }
          enddate.config.min = laydatechange(date);
        }
      });
      var enddate = laydate.render({
        elem: '#endTime',
        type: 'datetime',
        theme: '#2180d4',
        value: endDay,
        btns: ['now', 'confirm'],
        min: 0
      });
    });
  } else {
    layui.use('laydate', function () {
      var laydate = layui.laydate;
      laydate.render({
        elem: '#beginTime',
        type: 'datetime',
        theme: '#2180d4',
        value: new Date(today.setMonth((new Date().getMonth() - 3))).Format("yyyy-MM-dd 00:00:00"),
        btns: ['now', 'confirm'],
        max: new Date().pattern("yyyy-MM-dd HH:mm:ss"),
        done: function (value, date) {
          var starttime = value.replace(/-/g, "/"),
            d1 = (new Date(starttime)).getTime(),
            endtime = ($("#endTime").val()).replace(/-/g, "/"),
            d2 = (new Date(endtime)).getTime();
          if (d1 > d2) {
            $("#endTime").val('');
          }
          enddate.config.min = laydatechange(date);
        }
      });
      var enddate = laydate.render({
        elem: '#endTime',
        type: 'datetime',
        theme: '#2180d4',
        value: endDay,
        btns: ['now', 'confirm'],
        min: 0
      });
    });
  }
  //显示无牌车添加事件获取点击的值
  layui.use(['layer', 'form'], function () {
    var layer = layui.layer,
      $ = layui.jquery,
      form = layui.form; //必须先声明
  });
}

function init () {
  getSiteDeviceId(getUrlParam("devid"))
  searchGCGK();
  $("#jsjb_table").hide()
  initOutLook();
  initCondition();
  // searchInfo(page, type);
  initMap();
  queryZBYSGD(); //查询工地源头详情周边疑似工地

  if (getUrlParam("isflag") == 230) {
    $("#right_form").show()
    $("#ztcjg_r_tip").show()
    $("#jsjb_table").hide()
    $("#ztcjgBTN").addClass("sec")
    $("#ztcjgHDYP").removeAttr("class");
    $("#zbsxtBTN").removeAttr("class");
    $("#ztcjgWBTN").removeAttr("class");
    $("#ztcjgWBTN1").removeAttr("class");
    $("#jscb").removeAttr("class");
    $("#ztcjg")[0].style.display = "";
    $("#zbsxt")[0].style.display = "none";
    $(".sp_right")[0].style.display = "none";
    $("#gdxx_btn3").css("display", "block");
    $("#judgeDis")[0].style.display = "none"
    videoStopFuc();
    searchInfo(page, 1);
  } else {
    searchInfo(page, type);
  }
}

var outlookIds = '0';

function initOutLook () {
  $.ajax({
    type: 'get',
    dataType: "json",
    data: {
      GDID: getUrlParam("devid")
    },
    url: siteUrl_port + "/VIAS/web/site/selectOUTLOOKByGDID",
    // url: "http://127.0.0.1:8014/VIAS/web/site/selectOUTLOOKByGDID",
    success: function (data) {
      // console.log(data)
      for (i in data) {
        outlookIds = outlookIds + data[i].SBBH + ","
      }
      if (outlookIds.length > 2) {
        outlookIds = outlookIds.substring(1, outlookIds.length - 1)
      }

    }
  })
}

var oneCarInfoStatus = false;

//切换到渣土车内监管
$("#ztcjgBTN").click(function () {
  $("#right_form").show()
  $("#ztcjg_r_tip").show()

  $("#jsjb_table").hide()
  $("#ztcjgBTN").addClass("sec")
  $("#ztcjgHDYP").removeAttr("class");
  // $("#spjkBTN").removeAttr("class");
  $("#zbsxtBTN").removeAttr("class");
  $("#ztcjgWBTN").removeAttr("class");
  $("#ztcjgWBTN1").removeAttr("class");
  $("#jscb").removeAttr("class");
  $("#ztcjg")[0].style.display = "";
  // $("#spjk")[0].style.display="none";
  $("#zbsxt")[0].style.display = "none";
  $(".sp_right")[0].style.display = "none";
  $("#gdxx_btn3").css("display", "block");
  $("#judgeDis")[0].style.display = "none"
  videoStopFuc()
  type = 1;
  searchInfo(page, type);
  closeSpk();
  var wsgLable = document.getElementById("wsg_lable");
  var jxxLable = document.getElementById("jxx_lable");
  wsgLable.style.display = "none";
  jxxLable.style.display = "none";
  oneCarInfoStatus = true;
})
//切换到渣土车外监管
$("#ztcjgWBTN").click(function () {
  $("#ztcjg_r_tip").show()
  $("#right_form").show()
  $("#jsjb_table").hide()
  type = 2;
  searchInfo(page, type);
  $("#ztcjgWBTN").addClass("sec")
  $("#ztcjgHDYP").removeAttr("class");
  // $("#spjkBTN").removeAttr("class");
  $("#zbsxtBTN").removeAttr("class");
  $("#ztcjgBTN").removeAttr("class");
  $("#ztcjgWBTN1").removeAttr("class");
  $("#jscb").removeAttr("class");
  $("#ztcjg")[0].style.display = "";
  // $("#spjk")[0].style.display="none";
  $("#zbsxt")[0].style.display = "none";
  $(".sp_right")[0].style.display = "none";
  $("#gdxx_btn3").css("display", "none");
  $("#judgeDis")[0].style.display = "none"
  videoStopFuc();
  closeSpk();
  var wsgLable = document.getElementById("wsg_lable");
  var jxxLable = document.getElementById("jxx_lable");
  wsgLable.style.display = "inline-block";
  jxxLable.style.display = "inline-block";
  oneCarInfoStatus = false;
})

//切换到接诉即办
$("#jscb").click(function () {
  $("#ztcjg_r_tip").hide()
  $("#right_form").hide()
  $("#jsjb_table").show()
  $("#jscb").addClass("sec")
  $("#ztcjgHDYP").removeAttr("class");
  $("#ztcjgWBTN").removeAttr("class")
  $("#zbsxtBTN").removeAttr("class");
  $("#ztcjgBTN").removeAttr("class");
  $("#ztcjgWBTN1").removeAttr("class");


  $("#ztcjg")[0].style.display = "";
  // $("#spjk")[0].style.display="none";
  $("#zbsxt")[0].style.display = "none";
  $(".sp_right")[0].style.display = "none";
  $("#gdxx_btn3").css("display", "none");
  $("#judgeDis")[0].style.display = "none"
  initJSJB();
  closeSpk();
})

var jsjb_page = 1;
var ksjb_rows = 10;

function initJSJB () {

  $.ajax({
    type: 'get',
    dataType: "json",
    data: {
      siteId: getUrlParam("devid"),
      page: jsjb_page,
      rows: ksjb_rows
    },
    url: siteUrl_port + "/VIAS/web/site/findJSCBBySiteIdForPage",
    // url: "http://127.0.0.1:8014/VIAS/web/site/findJSCBBySiteId",
    // url: "http://127.0.0.1:8014/VIAS/web/site/findJSCBBySiteIdForPage",
    success: function (data) {
      layui.use(['laypage', 'layer'], function () {
        var laypage = layui.laypage;
        laypage.render({
          elem: 'jsjb_laypage',
          curr: jsjb_page,
          limit: ksjb_rows,
          count: data.total, //数据总数，从服务端得到
          first: "首页",
          last: "尾页",
          layout: ['count', 'prev', 'page', 'next', 'skip'],
          theme: "#009cd2",
          jump: function (obj, first) {
            //首次不执行
            if (!first) {
              jsjb_page = obj.curr;
              ksjb_rows = obj.limit;
              //do something
              initJSJB()
            }
            $("#jsjb_table_tbody").html("");
            $("#ztcjgInfo").html("");
            var num = (jsjb_page - 1) * ksjb_rows
            var html
            $.each(data.list, function (i, rows) {
              i = i + num + 1;
              var content = rows.CONTENTS;
              var theme = rows.THEME;
              var option = rows.OPINION;
              var source = rows.LETTERSOURCE;
              if (rows.CONTENTS.length > 10) {
                content = rows.CONTENTS.substring(0, 10) + '...';
              }
              if (rows.THEME.length > 5) {
                theme = rows.THEME.substring(0, 5) + '...';
              }
              if (rows.OPINION.length > 10) {
                option = rows.OPINION.substring(0, 10) + '...';
              }
              if (rows.LETTERSOURCE.length > 5) {
                source = rows.LETTERSOURCE.substring(0, 5) + '...';
              }
              html += `<tr style=" border-bottom: 1px dashed rgb(32, 148, 183)" class="td_border">
                                <td style="padding: 15px 0;">` + i +
                `</td><td>` + new Date(rows.TIME).pattern("yyyy-MM-dd HH:mm:ss") +
                `</td><td>` + rows.STREET +
                `</td><td>` + rows.MAINTYPE +
                `</td><td>` + rows.MIDDELTYPE +
                `</td><td>` + rows.SUBTYPE +
                `</td><td>` + source +
                `</td><td title=` + rows.CONTENTS + `>` + content +
                `</td><td title=` + rows.THEME + `>` + theme +
                `</td><td title=` + rows.OPINION + `>` + option +
                `</td><td title=` + rows.HANDELSTATUS + `>` + rows.HANDELSTATUS +
                `</td><td title=` + rows.FEEDBACKSTATUS + `>` + rows.FEEDBACKSTATUS +
                `</td><td title=` + rows.SOLVESTATUS + `>` + rows.SOLVESTATUS +
                `</td><td title=` + rows.SATISFACTION + `>` + rows.SATISFACTION +
                `</td><td title=` + rows.REVIEWER + `>` + rows.REVIEWER + `</td></tr>`;

            })
            $("#jsjb_table_tbody").append(html);
          }
        });
      })

    }
  })
}
$("#ztcjgWBTN1").click(function () {
  $("#ztcjg_r_tip").show()
  $("#right_form").show()
  $("#jsjb_table").hide()
  type = 3;
  searchInfo(page, type);
  $("#ztcjgWBTN1").addClass("sec")
  // $("#spjkBTN").removeAttr("class");
  $("#ztcjgHDYP").removeAttr("class");
  $("#zbsxtBTN").removeAttr("class");
  $("#ztcjgWBTN").removeAttr("class")
  $("#ztcjgBTN").removeAttr("class");
  $("#jscb").removeAttr("class");
  // $("#ztcjgWBTN1").removeAttr("class");
  $("#ztcjg")[0].style.display = "";
  // $("#spjk")[0].style.display="none";
  $("#zbsxt")[0].style.display = "none";
  $(".sp_right")[0].style.display = "none";
  $("#gdxx_btn3").css("display", "none");
  $("#judgeDis")[0].style.display = "none"
  videoStopFuc()
  closeSpk();
  var wsgLable = document.getElementById("wsg_lable");
  var jxxLable = document.getElementById("jxx_lable");
  wsgLable.style.display = "inline-block";
  jxxLable.style.display = "inline-block";
  oneCarInfoStatus = false;
})
//切换到视频监控
//$("#spjkBTN").click(function () {
//    $("#spjkBTN").addClass("sec")
//    $("#ztcjgBTN").removeAttr("class");
//    $("#zbsxtBTN").removeAttr("class");
//    $("#spjk")[0].style.display="";
//    $("#ztcjg")[0].style.display="none";
//    $("#zbsxt")[0].style.display="none";
//    videoDisplayFucZD('11010812001320012552','videoElement')
//})
//切换到周边摄像头
$("#zbsxtBTN").click(function () {
  $("#ztcjg_r_tip").show()
  $("#jsjb_table").hide()
  $("#right_form").show()
  $("#zbsxtBTN").addClass("sec")
  $("#ztcjgHDYP").removeAttr("class");
  $("#ztcjgBTN").removeAttr("class");
  $("#ztcjgWBTN").removeAttr("class")
  $("#ztcjgWBTN1").removeAttr("class");
  $("#jscb").removeAttr("class");
  $("#zbsxt")[0].style.display = "";
  $("#ztcjg")[0].style.display = "none";
  $("#gdxx_btn3").css("display", "none");
  $("#judgeDis")[0].style.display = "none"
  if (ysgdCount == 0) {
    $(".sp_right")[0].style.display = "none";
  } else {
    $(".sp_right")[0].style.display = "block";
  }
  closeSpk();

})
function closeSpk () {
  $(".gdxx_btn").css("right", "0rem");
  $(".gdxx_btn2").css("right", "0rem");
  $(".gdxx_btn3").css("right", "0rem");
  $("#spl_res1").css("right", "-4.5rem");
  $("#spl_res2").css("right", "-4.5rem");
  $("#spl_res3").css("right", "-4.5rem");
}

$("#ztcjgHDYP").click(function () {
  // $("#judgeDis").css("z-index", "5")
  $("#ztcjg_r_tip").hide()
  $("#right_form").hide()
  $("#jsjb_table").hide()
  $("#ztcjgHDYP").addClass("sec")
  $("#judgeDis")[0].style.display = "block"
  $("#zbsxtBTN").removeAttr("class");
  $("#ztcjgWBTN").removeAttr("class")
  $("#ztcjgWBTN1").removeAttr("class");
  $("#ztcjgBTN").removeAttr("class");
  $("#jscb").removeAttr("class");
  $("#report").removeAttr("class");
  $("#zbsxt")[0].style.display = "none";
  $("#ztcjg")[0].style.display = "none";
  // $("#ztcjgHDYP").style.display = "none"

})
